perm filename HOSTAB.MID[NET,MRC]2 blob sn#318458 filedate 1977-11-20 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00005 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	title HOSTAB
C00003 00003	 I/O subroutines
C00005 00004	 Start of program
C00009 00005	hstprt:	skipg y,hsttab(a)		 get number of host
C00014 ENDMK
C⊗;
title HOSTAB

; Mark Crispin, SU-AI, November 1977
; Adapted from the ITS version

.insrt MACROS[1,MRC]

acdef. [x y z a b c]			; accumulators

nd. pdllen==50.				; push down list length

pdl:	block pdllen			; push down list
; I/O subroutines

; NOUT numeric output
; accepts in x:	base to use for outputting the number
;	     y:	number to be output
; returns:  +1:	always, with y and z clobbered

nout=call .
	idivi y,(x)			; get a digit
	save z				; save the lowest order digit left
	caxe y,%zeros			; got them all?
	 nout				; nope
	retr y				; get a digit to output
	addx y,"0			; convert to ASCII
	outchr y			; output it
	return				; and return

; SOUT string output
; accepts in x:	pointer to string (0 in LH means ASCIZ string)
; returns   +1:	always, with updated string pointer in x; 0 clobbered

sout=call .
	txnn x,%lhalf			; is there a left half?
	 hrli x,440700			; no, assume ASCII
	store %zeros,strlen'		; initialize string length
	ildb x				; get a character
	jumpe [return]			; return if null
	aos strlen'			; bump counter
	outchr				; and output character
	jrst .-4			; and try next
; Start of program

hostab:	move p,[pdl(-pdllen)]		; load PDP
	open [17 ? 'DSK,, ? 0]		; get a disk channel
	 jrst 4,.-1			; failed?
	movx x,'HOSTS1			; fn1
	movx y,('BIN)			; fn2
	movx z,%zeros			; protection trash
	movx a,'NETMRC			; ppn
	lookup x			; get host table
	 jrst [	outstr [asciz/Host table gone!/]
		jrst 4,.-1]
	movs x,a			; get -size
	movns x				; positive
	addi x,hsttab			; offset for address
	core x,				; get necessary core
	 jrst 4,.-1
	hrri a,hsttab-1			; make IOWD pointer
	movx b,%zeros			; and stop code
	in a				; read file in
	 skipn x,hsttab			; check first word of host table
	  jrst 4,.-1			; didn't read it all or bad?
	caxe x,'HOSTS1			; right first word?
	 jrst 4,.-1			; bad file?
	outstr [asciz/Host table generated by /]
	skipn x,hsttab+3		; get UNAME of creator
	 jrst 4,.-1			; null UNAME?
htbunm:	movx y,%zeros			; zap where character will go
	rotc x,6			; gobble a character
	addx y,<" >			; ASCIIify
	outchr y			; output
	jumpn x,htbunm			; continue if more
	outstr [asciz/ on /]
	skipn x,hsttab+4		; get compilation date
	 jrst 4,.-1			; null creation date?
	rot x,12.			; put year last
repeat 3,[
 repeat 2,[
	  movx y,%zeros			; zap character
	  rotc x,6			; gobble a character
	  addx y,<" >			; ASCIIify
	  outchr y			; output the character
 ]
 ifn .rpcnt-2,outchr ["/]		; output a slash
 .else	 outchr [" ]			; output a space last time
]
	skipn x,hsttab+5		; get compilation time
	 jrst 4,.-1			; null compilation time?
repeat 3,[
 repeat 2,[
	  movx y,%zeros			; zap character
	  rotc x,6			; gobble a character
	  addx y,<" >			; ASCIIify
	  outchr y			; output the character
 ]
 ifn .rpcnt-2,outchr [":]		; delimiter
]
	outstr [asciz/

Host #	Oct #	Official Name	Machine		System

/]
	skipg a,hsttab+7		; load address of NUMBERS table
	 jrst 4,.-1			; invalid address?
	skipg b,hsttab(a)		; load number of entries
	 jrst 4,.-1			; invalid number of entries?
	skipg c,hsttab+1(a)		; load number of words/entry
	 jrst 4,.-1			; invalid number of words?
	addx a,2			; point now to first entry
hstprt:	skipg y,hsttab(a)		; get number of host
	 jrst 4,.-1			; funny host number?
	movx x,"*			; assume a server
	skipl hsttab+2(a)		; but is it really?
	 movx x,<" >			; nope, a user
	outchr x ? outchr [" ]		; initial heading
	caxge y,1000.			; four digit number?
	 outchr [" ]			; three or less
	caxge y,100.			; three digit number?
	 outchr [" ]			; two or less
	caxge y,10.			; two digit number?
	 outchr [" ]			; one digit
	movx x,10.			; load up decimal base
	nout				; output it
	outchr [↑I]			; go to next field
	skipg y,hsttab(a)		; get the number again
	 outchr				; how can this happen??
	caxge y,1000			; four digit number?
	 outchr [" ]			; three or less
	caxge y,100			; three digit number?
	 outchr [" ]			; two or less
	caxge y,10			; two digit number?
	 outchr [" ]			; one digit
	movx x,8.			; load up octal base
	nout				; output it
	outchr [↑I]			; go to next field
	hrrz x,hsttab+1(a)		; get name of host
	jumpe x,[jrst 4,.]		; null host pointer?
	addi x,hsttab			; convert to absolute address
	sout				; output the string
	skipn x,strlen'			; get length of string
	 jrst 4,.-1			; null host name?
	caxge x,8.			; more than one field length?
	 outchr [↑I]			; yes, another tab required
	outchr [↑I]			; output another tab
	hrrz x,hsttab+2(a)		; get machine host is
	jumpe x,[	movei x,[asciz/UNKNOWN/]; unknown name
			jrst .+2]	; and continue
	addi x,hsttab			; convert to absolute address
	move y,(x)			; get first word of machine name
	andx y,777777700000		; get first three characters
	caxn y,ascii/PDP/		; is this a PDP-nn?
	 jrst [	ldb y,[100700,,(x)]	; yes, get fourth character
		caxn y,"-		; is it a dash?
		 jrst .+1		; yes (foo, somebody lost!)
		save x			; save current pointer
		outstr [asciz/PDP-/]
		retr x			; get current pointer back
		hrli x,170700		; kludge up byte pointer after PDP
		jrst .+1]		; what a crock!
	sout				; and output it
	skipn x,strlen'			; get length of string
	 jrst 4,.-1			; null host name?
	caxge x,8.			; more than one field length?
	 outchr [↑I]			; yes, another tab needed
	outchr [↑I]			; output a delimiting tab
	hlrz x,hsttab+1(a)		; get system host has
	jumpe x,[	movei x,[asciz/UNKNOWN/]; unknown system
			jrst .+2]	; and continue
	addi x,hsttab			; convert to absolute address
	sout				; and output it
	outstr [asciz/
/]
	addi a,(c)			; go to next entry in the table
	sojg b,hstprt			; loop for next entry
	outstr [asciz/
* means this site is a server
/]
	exit				; suicide

; Generate literals

	variables ? constants

hsttab:					; start of host table

	end HOSTAB